Crate crypto_bigint[][src]

Expand description

Pure Rust implementation of a big integer library designed for cryptography.

About

This library has been designed from the ground-up for use in cryptographic applications. It provides constant-time, no_std-friendly implementations of modern formulas implemented using const generics.

Minimum Supported Rust Version

Rust 1.51 at a minimum.

Goals

  • No heap allocations i.e. no_std-friendly.
  • Constant-time by default using traits from the subtle crate.
  • Leverage what is possible today with const generics on stable rust.
  • Support const fn as much as possible, including decoding big integers from bytes/hex and performing arithmetic operations on them, with the goal of being able to compute values at compile-time.

Status

This library presently provides only a baseline level of functionality. It’s new, unaudited, and may contain bugs. We recommend that it only be used in an experimental capacity for now.

Please see the feature wishlist tracking ticket for more information.

Re-exports

pub use crate::limb::Limb;
pub use subtle;
pub use generic_array;
pub use rlp;
pub use zeroize;

Modules

constsgeneric-array

Type aliases for many constants.

Big integers are represented as an array of smaller CPU word-size integers called “limbs”.

Macros

Calculate the number of limbs required to represent the given number of bits.

Structs

Provides intentionally-checked arithmetic on T.

Wrapper type for non-zero integers.

Big unsigned integer.

Provides intentionally-wrapped arithmetic on T.

Constants

LIMB_BYTESDeprecated64-bit

Number of bytes in a Limb.

Traits

Compute self + rhs mod p.

ArrayDecodinggeneric-array

Support for decoding a GenericArray as a big integer.

ArrayEncodinggeneric-array

Support for encoding a big integer as a GenericArray.

Concatenate two numbers into a “wide” twice-width value, using the rhs value as the least significant value.

Encoding support.

Integer type.

Compute self * rhs mod p.

Compute -self mod p.

Randomrand

Random number generation support.

Modular random number generation support.

Split a number in half, returning the most significant half followed by the least significant.

Compute self - rhs mod p.

Type Definitions

ByteArraygeneric-array

Alias for a byte array whose size is defined by ArrayEncoding::ByteSize.

64-bit unsigned big integer

128-bit unsigned big integer

192-bit unsigned big integer

256-bit unsigned big integer

384-bit unsigned big integer

448-bit unsigned big integer

512-bit unsigned big integer

768-bit unsigned big integer

896-bit unsigned big integer

1024-bit unsigned big integer

1536-bit unsigned big integer

1792-bit unsigned big integer

2048-bit unsigned big integer

3072-bit unsigned big integer

3584-bit unsigned big integer

4096-bit unsigned big integer

6144-bit unsigned big integer

8192-bit unsigned big integer